package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.domain.StrategyDetail;
import cn.wolfcode.luowowo.article.domain.TravelCommend;
import cn.wolfcode.luowowo.article.query.TravelCommendQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.article.service.IStrategyDetailService;
import cn.wolfcode.luowowo.article.service.ITravelCommendService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("travelCommend")
public class TravelCommendController {
    @Reference
    private ITravelCommendService travelCommendService;
    @Reference
    private IStrategyDetailService strategyDetailService;

    @RequestMapping("list")
    public String list(Model model,TravelCommendQuery qo){
        PageInfo pageInfo = travelCommendService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        List<StrategyDetail> details = strategyDetailService.list();
        model.addAttribute("details",details);
        return "travelCommend/list";
    }

    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public AjaxResult saveOrUpdate(TravelCommend travelCommend){
        travelCommendService.saveOrUpdate(travelCommend);
        return new AjaxResult();
    }

    @RequestMapping("delete")
    @ResponseBody
    public AjaxResult delete(Long id){
        travelCommendService.delete(id);
        return new AjaxResult();
    }
}
